package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.Strategy;
import cn.wolfcode.trip.base.domain.StrategyContent;
import cn.wolfcode.trip.base.mapper.StrategyContentMapper;
import cn.wolfcode.trip.base.mapper.StrategyMapper;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IStrategyService;
import cn.wolfcode.trip.base.service.IStrategyService;
import cn.wolfcode.trip.base.util.UserContext;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class StrategyServiceImpl implements IStrategyService{
    @Autowired
    private StrategyMapper strategyMapper;

    @Override
    public void saveOrUpdate(Strategy entity) {
        if (entity.getId() == null) {
            strategyMapper.insert(entity);

        }else{
            strategyMapper.updateByPrimaryKey(entity);

        }
    }

    @Override
    public PageInfo list(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<Strategy> list = strategyMapper.selectForList(qo);
        return new PageInfo<>(list);
        
    }

    @Override
    public Strategy selectById(Long id) {
        return strategyMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Strategy> selectAll() {
        return strategyMapper.selectAll();
    }



}
